<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
    <meta http-equiv="X-UA-Compatible" content="IE=emulateIE7" />
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <meta name="viewport" content="initial-scale=1.0, user-scalable=no" />
    <link rel="stylesheet" href="/static/base/common/css/sapar.css" />
    <link rel="stylesheet" type="text/css" href="/static/base/common/css/common.css" />
    <link rel="stylesheet" type="text/css" href="/static/webjars/layui/css/layui.css"/>
    <script type="text/javascript" src="/static/base/common/js/jquery.js"></script>
    <script type="text/javascript" src="/static/base/common/js/sapar.js"></script>
    <title>综合评价查询</title>
    <style>
        #mapContainer{height:600px}
        <%--百度地图取消显示logo--%>
        .BMap_cpyCtrl {display: none;}
        .anchorBL {display: none;}
        .search{
            padding:15px 10px;
        }
        .search button{
            background-color:rgb(59,159,225);
        }
    </style>
</head>

<body>
<div id="saper-container">
    <div id="saper-hd">
    </div>
    <div id="saper-bd">
        <div class="subfiled clearfix">
            <h2>综合评价查询</h2>
        </div>
        <div class="search">
            搜索ID：
            <div class="layui-inline">
                <input class="layui-input" name="id" id="number" autocomplete="off">
            </div>
            <button class="layui-btn" data-type="reload">搜索</button>
        </div>
        <table id="evaluate" lay-filter="data"></table>
    </div>
    <div id="saper-ft"></div>
</div>
</body>
<script type="text/javascript" src="/static/webjars/layui/layui.js"></script>
<script type="text/html" id="manage">
    <a class="layui-btn layui-btn-xs" lay-event="detail">详情</a>
    <a class="layui-btn layui-btn-danger layui-btn-xs" lay-event="del">删除</a>
</script>
<script type="text/javascript">
layui.use('table',function(){
    var table = layui.table;
    //加载数据
    table.render({
        elem: '#evaluate'
        ,height: 'full-200'
        ,url: '/ajax/commandajax/evaluates' //数据接口
        ,page: true //开启分页
        ,cols: [[ //表头
            { title: 'ID',width:80,sort: true, fixed: 'left',templet:function(d){
                    return d.id;
                }}
            ,{title: '评价人',width:100,sort:true,templet:function(d){
                    if(d.name === undefined || d.name === null){
                        return "未分配";
                    }
                    return d.name;
                }}
            ,{title: '报备时间',width:150,sort:true,templet:function(d){
                    var date = new Date(Number(d.startTime));

                    var year = date.getFullYear(),
                        month = date.getMonth() + 1,//月份是从0开始的
                        day = date.getDate(),
                        hour = date.getHours(),
                        min = date.getMinutes(),
                        sec = date.getSeconds();
                    var newTime = year + '-' +
                        month + '-' +
                        day + ' ' +
                        hour + ':' +
                        min + ':' +
                        sec;
                    return newTime;
                }}
            ,{title: '结案时间',width:180,templet:function(d){
                    return d.endTime;
                }}
            ,{title:'案件地点',width:178,templet:function(d){
                    return d.addr;
                }}
            ,{title: '案件内容',templet:function(d){
                    return d.content;
                }}
            ,{title:'评价',templet:function(d){
                    if(d.commemt === undefined || d.commemt === null){
                        return "未评价";
                    }
                    return d.commemt;
                }}
            ,{toolbar:'#manage',title:'操作',align:'center',fiexd:'left',width:178}
        ]]
        ,id: 'reload'
        ,page: true
        ,height:  'full-200'
    });
    //点击事件
    table.on('tool(data)', function(obj){
        var data = obj.data;
        console.log(data);
        if(obj.event === 'detail'){
            layer.open({
                type: 2,
                title:'',
                closeBtn:0,
                shadeClose:true,
                offset:['100px','500px'],
                area:['870px','500px'],
                content: ['/command/evaluate_detail?id='+data.id]
            });
        } else if(obj.event === 'del'){
            layer.confirm('你确定删除此事件?', {icon: 3, title:'提示',aim:5, offset:['300px','800px']}, function(index){
                obj.del();
                layer.close(index);
            });
        } else if(obj.event === 'edit'){
            layer.alert('编辑行:'+ JSON.stringify(data));
        }
    });

    //定义搜索事件
    var $ = layui.$,active = {
        reload: function(){
            var number = $('#number');

            //执行重载
            table.reload('reload', {
                page: {
                    curr: 1 //重新从第 1 页开始
                }
                ,where: {
                    key: {
                        id: number.val()
                    }
                }
            });
        }
    };

    $('.search .layui-btn').on('click', function(){
        var type = $(this).data('type');
        active[type] ? active[type].call(this) : '';
    });
});
</script>
</html>